package com.xiaotou.struts.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;
import com.xiaotou.db.pojo.WbUser;
import com.xiaotou.domain.Engine;
import com.xiaotou.domain.Role;
import com.xiaotou.service.UserService;
import com.xiaotou.utils.AuthUtils;
import com.xiaotou.weibo.WeiboClientException;
import com.xiaotou.weibo.WeiboFactory;

public class AchievementAction extends ActionSupport {

	private static final long serialVersionUID = -6885617094243972818L;

	private Engine engine;
	private UserService userService;
	private Role role;

	@Action(value = "/achievement", results = { @Result(name = "success", location = "/WEB-INF/jsp/achievement.jsp") })
	public String getRandomPreys() throws WeiboClientException {
		WbUser loginUser = AuthUtils.getLoginUser();
		this.role = this.engine.actThief(WeiboFactory
				.createWeiboUser(loginUser));
		return SUCCESS;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public void setEngine(Engine engine) {
		this.engine = engine;
	}

	public Role getRole() {
		return role;
	}

}
